package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.BaseCategory3;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *
 * @author sun
 */
@Mapper
public interface BaseCategory3Mapper extends BaseMapper<BaseCategory3> {

    @Select("""
            select t2.id,t2.category2_id,t2.name,t2.order_num,t2.is_top
            from
            base_category2 as t1
            join base_category3 as t2
            on t1.id = t2.category2_id
            where t1.category1_id = #{category1Id}
            and t1.is_deleted = 0
            and t2.is_deleted = 0
            and t2.is_top = 1
            order by t1.order_num DESC, t2.order_num DESC
            limit 7
            """)
    List<BaseCategory3> selectTopBaseCategory3(@Param("category1Id")Long category1Id);
}
